package cn.com.jrr.core.common.mytag;

import java.io.IOException;
import java.util.Date;

import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspWriter;

import org.springframework.web.servlet.tags.RequestContextAwareTag;

import cn.com.jrr.core.common.StringUtils;

public class TagPopupTable extends RequestContextAwareTag {

    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private String itemTitle;
    private String title;
    private String id;
    @Override
    protected int doStartTagInternal() throws JspTagException{
        JspWriter out = pageContext.getOut();
        StringBuffer sb = new StringBuffer();
        String [] itemTitleArray=null;
        if(StringUtils.isBlank(itemTitle)){
            itemTitleArray=itemTitle.split(",");
        }

        //sb.append("<div>\r\n");
        /*sb.append("<button type='button'");
        if(StringUtils.isBlank(btnClass)){
        	sb.append(" class='"+btnClass+"'");
        }else{
        	sb.append(" class='btn btn-myself'");
        }
        sb.append(" id='"+btnSelectId+"'");
        sb.append(" onclick=\"CONSTANT.FUNCTION.popupdialogfun(\'"+itemText+"\',\'"+url+"\',\'"+tableId+"\',\'"+dialogDivId+"\',\'"+fuzzySearchId+"\',\'"+btnSearchId+"\',\'"+popupParam+"\')\"");
        if(StringUtils.isBlank(iconClass)){
        	sb.append("><i class='"+iconClass+"'></i> "+btnText+"</button>");
        }else{
        	sb.append("><i class='fa fa-ok'></i> "+btnText+"</button>");
        }*/
        sb.append("<div class='win_hidden_div'>\r\n");
        sb.append("<div id='"+id+"' title='"+title+"'>\r\n");
        sb.append("<div class='btn-toolbar'>\r\n");
        sb.append("<div class='pull-right'>\r\n");
        sb.append("<div class='input-append'>\r\n");
        sb.append("<input type='text' placeholder='输入查询关键字'>\r\n");
        sb.append("<div class='btn-group'>\r\n");
        sb.append("<button type='button' class='btn btn-myself btn-sm'><i class='fa fa-search'></i>查询</button>\r\n");
        sb.append("</div>\r\n");
        sb.append("</div>\r\n");
        sb.append("</div>\r\n");
        sb.append("</div>\r\n");
        sb.append("<table class='table table-bordered hover' border='1' width='100%'>\r\n");
        sb.append("<thead>\r\n");
        sb.append("<tr>\r\n");
        sb.append("<th><input type='checkbox' name='cb-check-all'></th>\r\n");
        for(int i=0;i<itemTitleArray.length;i++){
            sb.append("<th>"+itemTitleArray[i]+"</th>\r\n");
        }
        sb.append("</tr>\r\n");
        sb.append("<thead>\r\n");
        sb.append("<tbody></tbody>\r\n");
        sb.append("</table>\r\n");
        sb.append("</div>\r\n");
        sb.append("</div>\r\n");
        //sb.append("</div>\r\n");
        System.out.println(sb.toString());
        try {
            out.print(sb.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return EVAL_PAGE; // 表示处理完标签后继续执行以下的JSP网页
        // return SKIP_PAGE; //表示不处理接下来的JSP网页
    }
    public String getItemTitle() {
        return itemTitle;
    }
    public void setItemTitle(String itemTitle) {
        this.itemTitle = itemTitle;
    }

    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }

}
